package com.example.controller;

import com.example.entity.User;
import com.example.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/provider")
public class UserController {

    @Autowired
    UserService userService;

    @Value("${server.port}")
    String port;

    @GetMapping("/user")
    public List<User> findUser(HttpServletRequest request){
        log.info(port+"------"+request.getHeader("name"));
        return userService.findUser();
    }

    @GetMapping("/get")
    public String get(@RequestHeader("X-Request-color") String red){
        return red;
    }
}
